USE [movie]
GO

/****** Object:  StoredProcedure [dbo].[mov_insertCustomer]    Script Date: 05/31/2011 18:11:46 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT name FROM sysobjects WHERE name = 'mov_insertCustomer' AND type = 'P') DROP PROCEDURE mov_insertCustomer
GO








-- =============================================
-- Modified:    Pritam Bhat
-- Create date: 5/24/2011
-- Description:	This procedure inserts  customer details

-- =============================================
CREATE PROCEDURE [dbo].[mov_insertCustomer] 	
(
	@email varchar(40),
	@password varchar(10),
	@name varchar(30),
	@address varchar(40),
	@city varchar(20),
	@zip varchar(20),
	@stateid int
)
AS
BEGIN

	Declare @custnumber int;
	Set @custnumber = (Select max(cus_ID) from dbo.customer) + 1
	Select @custnumber
	
	INSERT INTO dbo.customer
     VALUES
           (@custnumber,@name, getDate(), @email, @password)
  
	Declare @addrnumber int;
	Set @addrnumber = (Select max(address_id) from dbo.customer_address) + 1
	Select @addrnumber
	         
    Insert into dbo.customer_address
		VALUES
			(@addrnumber, @custnumber, @address, @city, @zip, @stateid)
			
           
    
	

END





GO


